<?php
class SupportOnline_Model_Support extends Zend_Db_Table{
	protected $_name = 'support';
	protected $_primary = 'suppord_id';
	/* Link tham khao : http://framework.zend.com/manual/en/zend.db.table.html */
	/* select demo */
	public function getAllSupporter()
	{// co dung
		
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/support/route/getAllSupporter");
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
		
	}
	public function insertNewSupport($data)
	{// co dung
		$data['route'] = "insertNewSupport";
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restPost("/support", $data);

		return $return->getBody();
	}
	public function getSupportById($id)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/support/route/getSupportById/id/".$id);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);

		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
	}
	public function updateSupport($id,$data)
	{ // co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restPut("/support/route/updateSupport/id/".urlencode($id)."/data1/".urlencode($data['support_name'])."/data2/".urlencode($data['support_position'])."/data3/".urlencode($data['phone'])."/data4/".urlencode($data['skype'])."/data5/".urlencode($data['yahoo'])."/data6/".urlencode($data['created_date'])."/data7/".urlencode($data['updated_date']));
		return $return->getBody();
		
	}
	public function deleteSupport($id)
	{// co dung
		
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restDelete("/support/route/deleteSupport/id/".$id);
		return $return->getBody();
		
	}
}